Scheduler for WPF | ComponentOne
C1.WPF.Schedule Namespace / PropertyBridge<TPropType> Class
Defines a type of exposed dependency properties.
Members

In This Topic
    PropertyBridge<TPropType> Class
    In This Topic
    Represents a class that exposes two dependency properties and keeps their values equal.
    Object Model
    PropertyBridge<TPropType> Class
    Syntax
    'Declaration
     
    
    Public Class PropertyBridge(Of TPropType) 
       Inherits System.Windows.FrameworkElement
    public class PropertyBridge<TPropType> : System.Windows.FrameworkElement 
    Type Parameters
    TPropType
    Defines a type of exposed dependency properties.
    Remarks
    For a usage in XAML appeal to the non-generic class derived from the PropertyBridge<TPropType>, for example use the PropertyBridge class.

    PropertyBridge<TPropType> exposes two dependency properties, Source and Target, and keeps these property values equal, that is when a value of one property is being changed then the other property is being set to the same value. This simple behavior allows you to use non-DependencyProperty properties along with WPF mechanisms that are designed to work with DependencyProperty-only properties.

    The behavioral difference between the Source and Target properties lies in the fact that after an initialization of XAML tree where the PropertyBridge<TPropType> element is included, the Target property value is initialized with the Source property value – in all other respects the behavior of these properties is equivalent.

    Note that if you need to use PropertyBridge<TPropType> as a standalone object in run-time, that is without including it in a XAML tree, you need to call its BeginInit and EndInit methods – only after this action PropertyBridge<TPropType> will start property value synchronization.

    The useful examples of the PropertyBridge<TPropType> class usage are:

    • Assign the Source property with a TwoWay binding having one non-dependency property as a source, and the Target property with a TwoWay binding having another non-dependency property as a source. After this, the non-dependency properties will behave as bound ones. This only works well if classes exposing the mentioned non-dependency properties implement the System.ComponentModel.INotifyPropertyChanged interface.
    • Assign the Source property with a TwoWay or OneWayToSource binding having one non-dependency property as a source, and by specifying a Trigger's Setter set a value to the Target property of PropertyBridge<TPropType> – this value will be assigned to the non-dependency property which is bound to Source.
    • Assign the Source and Target with MultiBinding bindings – you will get the many-to-many binding.
    • Set up the Target property with a TwoWay or OneWayToSource binding where Binding.Path references a nested property, then assign the Source property (directly or from within a Setter) with a value - as a result the nested property will be assigned to this value.
    • Similar to the way explained in the previous item, and using Binding.RelativeSource in a binding to the Target property, you may assign a property value of an element that can't be referenced directly in XAML, for example TemplatedParent or some parent element in visual tree.

    The PropertyBridge<TPropType> class is derived from the System.Windows.FrameworkElement class and, in order to work properly, should be placed somewhere in the visual tree among elements that it should communicate with. The derivation from the System.Windows.FrameworkElement class is intentional; it allows the PropertyBridge<TPropType> to be part of a visual tree, which in turn provides bindings established on its properties with a correct context.

    The System.Windows.UIElement.Visibility property of the PropertyBridge<TPropType> element is set to Collapsed by default, so this object will not appear on a screen and doesn't participate in layout measurement and arrangement processes, that is, it doesn't affect a visual representation of the visual tree where it placed in.

    Inheritance Hierarchy

    System.Object
       System.Windows.Threading.DispatcherObject
          System.Windows.DependencyObject
             System.Windows.Media.Visual
                System.Windows.UIElement
                   System.Windows.FrameworkElement
                      C1.WPF.Schedule.PropertyBridge<TPropType>
                         C1.WPF.Schedule.PropertyBridge

    See Also